package com.wx.baseio;

import java.util.ArrayList;

public class Utf8ToHex {
    public static void main(String[] args) {




        // utf8 转换为 16进制


        ArrayList<String> list = new ArrayList<>();
        list.add(getStringBuilder("AT+WKMOD=NET"));
        list.add(getStringBuilder("AT+SOCKA=TCP,222.35.42.177,54001"));
        list.add(getStringBuilder("AT+S"));
        list.add(getStringBuilder("AT+Z"));
        list.add(getStringBuilder("AT+CSQ"));
        list.add(getStringBuilder("AT+WKMOD"));
        list.add(getStringBuilder("usr.cn#AT+SOCKA"));
        list.add(getStringBuilder("usr.cn#AT+WKMOD"));
        list.add(getStringBuilder("usr.cn#AT+CAN"));
        list.add(getStringBuilder("usr.cn#AT+UART2NET=ON,ON"));
        list.add(getStringBuilder("usr.cn#AT+S"));
        list.add(getStringBuilder("usr.cn#AT+CAN=500000,0,BASIC,NONE,0,0"));
        list.add(getStringBuilder("usr.cn#AT+CAN=500000,0,BASIC,STDRECV,5,55"));
        list.add(getStringBuilder("usr.cn#AT+HEARTEN=OFF"));
        list.add(getStringBuilder("usr.cn#AT+REGDT?"));
        list.add(getStringBuilder("usr.cn#AT+REGEN?"));
        list.add(getStringBuilder("usr.cn#AT+REGEN=ON"));
        list.add(getStringBuilder("usr.cn#AT+REGTP?"));
        list.add(getStringBuilder("usr.cn#AT+REGDT=1AAA"));
        list.add(getStringBuilder("usr.cn#AT+REGSND=DATA"));
        list.add(getStringBuilder("usr.cn#AT+CANFL=1"));

        // 41 54 2b 53 41 46 45 41 54 45 4e 0D 0A
        // 0x0D 0x0A
       list.forEach(System.out::println);
    }

    private static String getStringBuilder(String str) {

        byte[] bytes = str.getBytes();
        StringBuilder sb = new StringBuilder();
        for (byte b : bytes) {
            sb.append(Integer.toHexString(b & 0xff));
        }
        sb.append("0D0A");
        return str+":"+sb.toString();
    }
}
